package _4ChapterFore._4RemoveControlFlag;

import java.util.List;

public class UseReturnInsteadOfFlag {
    public void sendAlert(){}

    public String checkSecurity1(List<String> list){
        String find = "";
        for(String s:list){
            if("".equals(find)) {
                if ("trmp".equals(s)) {
                    sendAlert();
                    find = "trmp";
                }
                if ("job".equals(s)) {
                    sendAlert();
                    find = "job";
                }
            }
        }
        return find;
    }

    public String checkSecurity2(List<String> list){
        for(String s:list){
            if ("trmp".equals(s)) {
                sendAlert();
                return "trmp";
            }
            if ("job".equals(s)) {
                sendAlert();
                return "job";
            }
        }
        return "";
    }
}
